package com.ubtrobot.serialportlib.serial;

import android.util.Log;


import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;

/**
 * Description
 *
 * @author jianlin.duan
 * 2020/11/11, Create file
 */
public class SerialWriter {

    private final OutputStream mOutputStream;

    public SerialWriter(OutputStream outputStream){
        mOutputStream = outputStream;
    }

    public void write(String data) {
        try {
            //byte[] temp = ConvertUtils.hexString2Bytes(data);
            byte[] temp = new byte[]{};
            mOutputStream.write(temp);
            mOutputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void write(byte[] data) {
        try {
            Log.e("SerialWriter", Arrays.toString(data));
            //byte[] temp = ConvertUtils.hexString2Bytes(data);
            mOutputStream.write(data);
            mOutputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
